package com.xbongbong.saas.factory.business;

import com.xbongbong.paas.constant.PaasConstant;
import com.xbongbong.saas.enums.CompanyConfigEnum;
import com.xbongbong.saas.service.AccordConfigAddMenuHandle;
import com.xbongbong.saas.service.BatchFlowBillService;
import com.xbongbong.saas.service.ProductSerialService;
import com.xbongbong.saas.service.StockFlowBillService;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

@Component
public class AccordConfigAddMendFactory {
    private final static Map<CompanyConfigEnum, AccordConfigAddMenuHandle> ADD_MENU_HANDLE_MAP = new ConcurrentHashMap<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);

    @Resource
    private BatchFlowBillService batchFlowBillService;
    @Resource
    private ProductSerialService productSerialService;
    @Resource
    private StockFlowBillService stockFlowBillService;


    @PostConstruct
    public void init() {
        ADD_MENU_HANDLE_MAP.put(CompanyConfigEnum.ENABLE_BATCH_SHELF_MANAGEMENT, batchFlowBillService);
        ADD_MENU_HANDLE_MAP.put(CompanyConfigEnum.ENABLE_SEQ_MANAGEMENT, productSerialService);
        ADD_MENU_HANDLE_MAP.put(CompanyConfigEnum.ENABLE_STOCK_FLOW_BILL, stockFlowBillService);
    }


    public static AccordConfigAddMenuHandle getByConfigEnum(CompanyConfigEnum companyConfigEnum) {
       return ADD_MENU_HANDLE_MAP.get(companyConfigEnum);
    }
}
